
import * as ActionTypes from '../../../constants/constants.js'
import * as util from '../../../util/utils.js'


export const orderList = (state = {
    pageNum: 0,
    nextPage: 1,
    pageSize: 10,
    list: []
}, action) => {
    switch (action.type) {
        case ActionTypes.orderList:
            action.data.pageSize = 10
            action.data.list = state.list.concat(action.data.list)
            return action.data
        case ActionTypes.orderListRefresh:
            return action.data
        case ActionTypes.orderListError:
            state.error = action.data.error
            return {
                ...state,
                ...action.data
            }
        case ActionTypes.orderListReset:
            return {
                pageNum: 0,
                nextPage: 1,
                pageSize: 10,
                list: []
            }
        default:
            return state;
    }
}
